import java.io.*;
import java.net.*;
import java.util.*;

/**
 * This program implements a simple server that listens to port 8189 and echoes back all client
 * input.
 * @version 1.20 2004-08-03
 * @author Cay Horstmann
 */
public class EchoServer
{
   public static void main(String[] args)
   {
	      try
	      {
	         // establish server socket
	         ServerSocket s = new ServerSocket(8190);

	         // wait for client connection
	         Socket incoming = s.accept();
	         try
	         {
	            InputStream inStream = incoming.getInputStream();
	            OutputStream outStream = incoming.getOutputStream();

	            Scanner in = new Scanner(inStream);
	            PrintWriter out = new PrintWriter(outStream, true /* autoFlush */);

	            out.println("Hello! Enter menu to continue,enter quit to exit.");

	            // 201521123113
	            boolean done = false;
	            while (!done && in.hasNextLine())
	            {
	               String line = in.nextLine();
	               if (line.trim().equals("quit")){ 
	            	   done = true;
	            	   out.println("quit succeed!");
	            	   }
	               else if(line.trim().equals("menu")){
	            	   out.println("1.****");
	            	   out.println("2.****");
	            	   out.println("3.****");
	            	   out.println("4.****");
	            	   done = false;
	               }
	            }
	         }
	         finally
	         {
	            incoming.close();
	         }
	      }
	      catch (IOException e)
	      {
	         e.printStackTrace();
	      }
	   }
}
